package com.ionehe.group.common.uaa.ex.enums;

import com.ionehe.group.common.uaa.ex.exception.BusinessException;

import java.util.Objects;

/**
 * Copyright (c) 2020 ionehe.com
 * Date: 2020/10/10
 * Time: 下午3:08
 *
 * @author 2020年 <a href="mailto:a@ionehe.com">秀</a>
 */
public enum SexType {

    /**
     * 0：未知
     */
    unknown(0, "未知"),
    /**
     * 1：男
     */
    man(1, "男"),
    /**
     * 2：女
     */
    woman(2,"女")
    ;

    private Integer value;

    private String des;

    SexType(Integer value, String des){
        this.value = value;
        this.des = des;
    }

    public static SexType from(Integer value) {
        if (value == null) {
            return null;
        }
        for (SexType status : SexType.values()) {
            if (Objects.equals(value, status.getValue())) {
                return status;
            }
        }
        throw new BusinessException(ErrorMessages.ILLEGAL_OPERATION.toString());
    }

    public Integer getValue() {
        return value;
    }

    public String getDes() {
        return des;
    }
}
